package com.shujia.day12;

import java.util.ArrayList;
import java.util.Collection;

/*
    boolean addAll(Collection c)
    boolean removeAll(Collection c)
    boolean containsAll(Collection c)
    boolean retainAll(Collection c)

 */
public class CollectionDemo2 {
    public static void main(String[] args) {
        //创建集合对象
        Collection c1 = new ArrayList();
        c1.add("java");
        c1.add("maven");
        c1.add("clickhouse");
        c1.add("redis");

        Collection c2 = new ArrayList();
        c2.add("java");
        c2.add("hadoop");
        c2.add("maven");
        c2.add("hive");
        c2.add("hbase");
        c2.add("数据采集");

        System.out.println("c1: "+c1);
        System.out.println("c2: "+c2);

        System.out.println("------------------------------");
        //boolean addAll(Collection c)
//        c1.addAll(c2);
//        System.out.println("c1: "+c1);
//        System.out.println("c2: "+c2);

        //boolean removeAll(Collection c)
//        c1.removeAll(c2);
//        System.out.println("c1: "+c1);
//        System.out.println("c2: "+c2);

        //boolean containsAll(Collection c)
//        System.out.println(c1.containsAll(c2));
//        System.out.println("c1: "+c1);
//        System.out.println("c2: "+c2);

        //boolean retainAll(Collection c) 求交集 将结果保存在调用方法的对象集合中
        c1.retainAll(c2);
        System.out.println("c1: "+c1);
        System.out.println("c2: "+c2);

    }
}
